import java.util.LinkedList;


public class NandGate extends BasicGate {
	
	public boolean calculateValue() {
		LinkedList<Gate> inputs = (LinkedList<Gate>)getInputGates();
				
		//Have we got at least 2 inputs? Yes: Calculate our output. No: Throw exception
		if(inputs.size() >= 2) {
			
			//One inputs ones(trues)? Yes; Return true(one). No: Return false(zero)
			for(Gate g : inputs) {
				if(g.getOutputValue() == false)
					return true;
			}			
			return false;
		}
		else
			throw new GateException("An nand-gate needs at least 2 inputs");
	}
	
}
